<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>定位居中</title>
    <style>
        div{
            width: 200px;
            height: 100px;
            background-color: #ff5252;

            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%,-50%);
        }
    </style>
</head>
<body>
<div></div>
</body>
</html>
